package com.leapp.sk.ui.activity.personal

import android.os.Bundle
import cc.vv.lkbasecomponent.http.LKHttp
import cc.vv.lkbasecomponent.http.lib.setting.Settings
import cc.vv.lklibrary.http.base.okhttpfactory.plugins.httpplugin.MediaTypeWrap
import com.example.baselibrary.util.LKToastUtil
import com.example.mvp.activity.BaseActivityMVP
import com.example.mvp.binder.BaseDataBinder
import com.leapp.sk.R
import com.leapp.sk.app.HELP_FEED_DETIAL
import com.leapp.sk.bean.request.personal.FeedBackDetialRequestEntity
import com.leapp.sk.bean.response.personal.FeedBackDetialResponseEntity
import com.leapp.sk.binder.BaseBinder
import com.leapp.sk.sever.personal.FeedBackDetialSever
import com.example.util.finallist.FEED_BACK_ID
import com.example.util.finallist.SKCODE_200
import com.leapp.sk.viewdelegate.personal.FeedBackDetialDelegate

/**
 * 反馈详情
 * @author  chaohaipeng  on 2018/8/9.
 */
class FeedBackDetialActicity :BaseActivityMVP<FeedBackDetialDelegate>(){
    /**
     * 反馈id
     */
    private var id:String?=""
    override fun initDate() {
        id= intent?.getStringExtra(FEED_BACK_ID)
        httpFeedDetial()
    }

    override fun bindEvenListener() {
    }

    override fun initView(p0: Bundle?) {
        viewDelegate.setTitle(resources.getString(R.string.string_feed_back_detial))
    }

    override fun getDelegateClass(): Class<FeedBackDetialDelegate> {
        return FeedBackDetialDelegate::class.java
    }

    override fun getDataBinder(): BaseDataBinder<*, *> {
        return BaseBinder()
    }

    /**
     * 获取反馈列表
     */
    private fun httpFeedDetial() {
        if (id==null){
            return
        }
        val feedBackDetialRequestEntity = FeedBackDetialRequestEntity()
        feedBackDetialRequestEntity.id=id!!
        LKHttp.post(HELP_FEED_DETIAL, feedBackDetialRequestEntity, FeedBackDetialResponseEntity::class.java, object : BaseCallBack<FeedBackDetialResponseEntity>(this) {
            override fun onSuccess(url: String?, resultText: String?, obj: FeedBackDetialResponseEntity?) {
                super.onSuccess(url, resultText, obj)
                if (obj?.code == SKCODE_200) {
                    FeedBackDetialSever.getInstance().binderData(this@FeedBackDetialActicity,viewDelegate,obj)
                }else{
                    LKToastUtil.showToastShort(obj?.message)
                }
            }
            override fun onFailure(url: String?, isLoading: Boolean, exceptionStr: String?) {
                super.onFailure(url, isLoading, exceptionStr)
                LKToastUtil.showToastShort(resources.getString(R.string.app_net_erro))
            }
        }
                , true, Settings(MediaTypeWrap.MEDIA_TYPE_FORM))

    }



}